<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>新增重点防控病患</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" th:href="@{/static/layui/css/layui.css}">

</head>

<body style="width: 800px;height: 600px;">
<!--编辑表单-->
<div id="editBook">
    <form class="layui-form" id="saveBook" style="margin-top:10px">
        <input type="hidden" name="id" id="id">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">患者姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" id="name" required lay-verify="required" autocomplete="off"
                           class="layui-input" placeholder="必填">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所患病情</label>
                <div class="layui-input-inline">
                    <select name ="type" lay-filter="levelM" >
                        <option value ="新冠肺炎" checked="checked">新冠肺炎</option>
                        <option value ="风疹" >风疹</option>
                        <option value ="黑热病" >黑热病</option>
                        <option value ="肺结核" >肺结核</option>
                        <option value ="病毒性肝炎" >病毒性肝炎</option>
                        <option value ="狂犬病" >狂犬病</option>
                        <option value ="伤寒" >伤寒</option>
                        <option value ="猩红热" >猩红热</option>
                        <option value ="登革热" >登革热</option>
                        <option value ="流行性感冒" >流行性感冒</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">临床表现</label>
                <div class="layui-input-block">
                    <textarea name="detail" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">入院日期</label>
                <div class="layui-input-inline">
                    <input type="date" name="joindate" id="joindate" required autocomplete="off"
                           class="layui-input"
                           lay-verify="date">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所在病房</label>
                        <div class="layui-input-inline">
                            <input type="text" name="place" id="place"
                                   autocomplete="off"
                                   placeholder="x号院-x层-x号房"
                                   class="layui-input">
                        </div>
            </div>
        </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">负责医生</label>
                    <div class="layui-input-inline">
                        <input type="text" name="doctor" id="doctor" required lay-verify="required" autocomplete="off"
                               class="layui-input" placeholder="必填">
                    </div>
                </div>
            </div>
        <div class="layui-form-item" style="margin-top:40px" id="check">
            <div class="layui-input-block">
                <button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="saveBook">保存</button>
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
            </div>
        </div>
    </form>
</div>


<script src="/static/js/jquery-1.11.3.min.js" th:src="@{/static/js/jquery-1.11.3.min.js}"></script>
<script src="/static/layui/layui.all.js" th:src="@{static/layui/layui.all.js}"></script>
<script src="/static/js/util.js" th:src="@{/static/js/util.js}"></script>

<!--ctx-->
<script th:replace="~{fragment::ctx}"/>

<script>
    var element, layer, laydate, form;

    $(function () {

        // 使用模块
        layui.use(['element', 'layer', 'laydate', 'form'], function () {
            element = layui.element;
            layer = layui.layer;
            laydate = layui.laydate;
            form = layui.form;
        });

        form.verify({
            integer:[
                /^[0-9]\d*$/
                ,'只能输入整数！'
            ]
        });


        //监听表单提交
        // 修改
        form.on('submit(saveBook)', function (data) {
            //layer.alert(JSON.stringify(data.field));
            $.ajax({
                url: ctx+'api/patient/save',
                type: 'POST',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (result) {
                    if (result.code == 200) {
                        // layer.msg("修改成功！", {icon: 6});
                        cleanForm("#saveBook");
                        layer.closeAll();//关闭所有的弹出层
                        top.$(".layui-show").find("iframe")[0].contentWindow.userTable.reload();
                    } else {
                        layer.alert(result.message);
                    }
                }
            });

            return false;

        });
    });


</script>
</body>

</html>